<template>
    <div style="width: 30%">
        <el-header>增加数据</el-header>
        <el-form :model="form">
            <el-form-item label="名称" :label-width="formLabelWidth">
                <el-input v-model="form.name" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="年龄" :label-width="formLabelWidth">
                <el-input v-model="form.age" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="地址" :label-width="formLabelWidth">
                <el-input v-model="form.address" autocomplete="off"></el-input>
            </el-form-item>
        </el-form>
        <span class="dialog-footer">
        <el-button type="primary" @click="AddData " style="float: right">确 定</el-button>
        </span>

        <el-header>删除数据</el-header>
        <el-form :model="delForm">
            <el-form-item label="姓名" :label-width="formLabelWidth">
                <el-input v-model="delForm.name" autocomplete="off"></el-input>
            </el-form-item>
        </el-form>
        <span class="dialog-footer">
        <el-button type="primary" @click="DelData " style="float: right">确 定</el-button>
    </span>
    </div>
</template>

<script>
    export default {
        name: "GoodsMGR",
        data() {
            return {
                show: false,
                form: {
                    name: "",
                    tell: "",
                    address: "",
                },
                delForm: {
                    name: ""
                },
                formLabelWidth: '120px'
            }
        },

        methods: {
            handleClose() {

            },

            AddData() {
                var that = this
                this.$axios.post('http://127.0.0.1:80/sales/addData/', {
                    name: this.form.name,
                    age: this.form.age,
                    address: this.form.address,
                }).then(function (response) {
                    console.log(response)
                }).catch(function (error) {
                    console.log(error);
                });
            },

            DelData() {
                var that = this
                this.$axios.get('http://127.0.0.1:80/sales/del/', {
                    name: this.delForm.name,
                }).then(function (response) {
                    console.log(response)
                }).catch(function (error) {
                    console.log(error);
                });
            },
        },

        created() {
            this.GetList();
        }
    }
</script>

<style scoped>

</style>